package com.yxuan.springboot.controller;

import com.yxuan.springboot.model.AllProfessional;
import com.yxuan.springboot.service.SchoolMajorRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import com.yxuan.springboot.model.SchoolMajorRelation;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 
 * @author zchao
 *   SchoolMajorRelation控制器
 * @date 2023-05-27 14:46:21
 */
@Controller
@Api(tags = "院校与专业关联表")
@RequestMapping(value = "/schoolmajorrelation", method = {RequestMethod.POST,RequestMethod.GET})
@CacheConfig(cacheNames = "schoolmajorrelation")//缓存名，和管理器中配置的一致
public class SchoolMajorRelationController extends BaseController<SchoolMajorRelation>{

    @Autowired
    private SchoolMajorRelationService schoolMajorRelationService;

    @ApiOperation(value = "查询某个学院的特色专业", notes = "查询某个学院的特色专业")
    @RequestMapping("/loadTotalBySchoolID")
    @ResponseBody
    @Cacheable(key = "'loadTotalBySchoolID-' + #schoolID",
            unless = "#result==null",
            condition = "#schoolID!=null")
    public List loadTotalPerBySchoolID(Long schoolID){
        List<AllProfessional> allProfessionals = schoolMajorRelationService.getTotalSpeBySchoolID(schoolID);
        return allProfessionals;
    }

    @ApiOperation(value = "查询某个学院的所有专业", notes = "查询某个学院的所有专业")
    @RequestMapping("/loadTotalProBySchoolID")
    @ResponseBody
    @Cacheable(key = "'loadTotalProBySchoolID-' + #schoolID",
            unless = "#result==null",
            condition = "#schoolID!=null")
    public List loadTotalProBySchoolID(Long schoolID){
        List<AllProfessional> allProfessionals = schoolMajorRelationService.getTotalProBySchoolID(schoolID);
        return allProfessionals;
    }

}
